package com.damocode.starter.httpclient.autoconfigure;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@ConfigurationProperties(prefix = HttpClientPoolProperties.HTTP_CLIENT_POOL_PREFIX)
public class HttpClientPoolProperties {

    public static final String HTTP_CLIENT_POOL_PREFIX  = "httpclient.pool";

    /**
     * 最大连接数。默认：64个
     */
    private int maxTotal = 64;

    /**
     * 设置每个主机地址的连接数。默认: 5个
     */
    private int defaultMaxPerRoute = 5;

    private int maxIdleConnections = 5;

    /**
     * 在连接池中最大的空闲时间(用于定期清理空闲连接),默认1分钟,单位：豪秒(ms)
     */
    private long maxIdleTimeMillis = 60000L;

    private long keepAliveDurationMillis = 5000L;

    /**
     * 连接上服务器(握手成功)的时间，超出该时间抛出connect timeout
     */
    private int connectionTimeoutMillis = 5000;

    /**
     * 服务器返回数据(response)的时间，超过该时间抛出read timeout
     */
    private int socketTimeout = 10000;

    /**
     * 从连接池中获取连接的超时时间，超过该时间未拿到可用连接，会抛出org.apache.http.conn.ConnectionPoolTimeoutException:
     * Timeout waiting for connection from pool
     */
    private int connectionRequestTimeout = 15000;

}
